Fix: Invalid JSON on gc-stats (#1801)#4
Open
MitchLewis930 wants to merge 1 commit intopr_054_beforefrom
Open
Conversation
* Fix: Invalid JSON on gc-stats Credits of this patch should be for @jdsundberg, who reported the issue but never sent a patch. Link to his bug report is below. Closes puma#1687. * Update tests so JSON response is correctly parsed JSON without a whitespace between key and values wasn't being correctly parsed (for example: `key: 'value'` was processed ok, but `key:'value'` wasn't).
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Bugbot Autofix is OFF. To automatically fix reported issues with Cloud Agents, enable Autofix in the Cursor dashboard.
|
|
||
| lines = body.split("\r\n") | ||
| json_line = lines.detect { |l| l[0] == "{" } | ||
| pairs = json_line.scan(/\"[^\"]+\": [^,]+/) |
There was a problem hiding this comment.
Inconsistent JSON parsing - first gc-stats call not updated
Low Severity
The control_gc_stats method parses the /gc-stats JSON response twice: once for gc_count_before and once for gc_count_after. The PR only updated the second parsing to use JSON.parse (line 199), while the first parsing (lines 179-184) still uses the old regex-based approach. This creates an inconsistency within the same method - both instances parse the same JSON format but use different parsing methods.
Additional Locations (1)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


PR_054
Note
Low Risk
Small change limited to
/gc-statsJSON serialization and its test; low likelihood of side effects outside the control endpoint response format.Overview
Fixes the
/gc-statscontrol endpoint to emit proper JSON by switching from manual string construction toGC.stat.to_json(and requiringjson).Updates the CLI control tests to parse the response with
JSON.parse(adding ajsonrequire) instead of a regex-based parser, ensuring the endpoint stays valid JSON.Written by Cursor Bugbot for commit 2db1ef1. This will update automatically on new commits. Configure here.